package com.zhn.evsi.client;

import com.dtflys.forest.annotation.*;
import com.zhn.evsi.domain.dto.evsi.assets.EvsiAssetListDTO;
import com.zhn.evsi.domain.dto.evsi.assets.EvsiAssetLocationDTO;
import com.zhn.evsi.domain.dto.evsi.assets.EvsiAssetNameDTO;
import com.zhn.evsi.interceptor.TokenExceptionInterceptor;
import com.zhn.evsi.interceptor.TokenInterceptor;
import org.springframework.stereotype.Component;

import java.math.BigInteger;
import java.util.List;

@Component
@BaseRequest(baseURL = "${eveData}${eveDataSns}", interceptor = TokenExceptionInterceptor.class)
@Retry(maxRetryCount = "3", maxRetryInterval = "1000")
public interface AssetsClient {

    /**
     * 查询资产
     * */
    // https://esi.evetech.net/latest/characters/2119634223/assets/?datasource=tranquility&page=1&token=
    @Request(
            url = "/characters/{characters}/assets/?datasource=tranquility&page={page}",
            type = "GET",
            interceptor = TokenInterceptor.class
    )
    List<EvsiAssetListDTO> assetList(@Var("characters") Integer characters, @Var("page") Integer pageNum);


    /**
     * 查询资产物品所在的地点的x，y，z的轴度
     * */
    // https://esi.evetech.net/latest/characters/2119634223/assets/locations/?datasource=tranquility&token=
    @Request(
            url = "/characters/{characters}/assets/locations/?datasource=tranquility",
            type = "POST",
            interceptor = TokenInterceptor.class
    )
    List<EvsiAssetLocationDTO> assetLocations(@Var("characters") Integer characters, @JSONBody List<BigInteger> itemIds);


    /**
     * 查询资产名称
     * */
    // https://esi.evetech.net/latest/characters/2119634223/assets/names/?datasource=tranquility&token=
    @Request(
            url = "/characters/{characters}/assets/names/?datasource=tranquility",
            type = "POST",
            interceptor = TokenInterceptor.class
    )
    List<EvsiAssetNameDTO> assetNames(@Var("characters") Integer characters, @JSONBody List<BigInteger> itemIds);

    /**
     * 查询军团资产
     * */
    // /corporations/{corporation_id}/assets/
    // https://esi.evetech.net/latest/corporations/98539082/assets/?datasource=tranquility&page=1&token=
    @Request(
            url = "/corporations/{corporationId}/assets/?datasource=tranquility&page={page}",
            type = "GET",
            interceptor = TokenInterceptor.class
    )
    List<EvsiAssetListDTO> assetCorpList(@Var("corporationId") Integer corporationId, @Var("page") Integer pageNum);

    // /corporations/{corporation_id}/assets/locations/
    @Request(
            url = "/corporations/{corporationId}/assets/locations/?datasource=tranquility",
            type = "POST",
            interceptor = TokenInterceptor.class
    )
    List<EvsiAssetLocationDTO> assetCorpLocations(@Var("corporationId") Integer corporationId, @JSONBody List<BigInteger> itemIds);

    // /corporations/{corporation_id}/assets/names/
    @Request(
            url = "/corporations/{corporationId}/assets/names/?datasource=tranquility",
            type = "POST",
            interceptor = TokenInterceptor.class
    )
    List<EvsiAssetNameDTO> assetCorpNames(@Var("corporationId") Integer corporationId, @JSONBody List<BigInteger> itemIds);
}
